fix: preserve turns added during hydration window in FlowChatStore - #2052
Open
xielixing wants to merge 1 commit into
Open
fix: preserve turns added during hydration window in FlowChatStore#2052xielixing wants to merge 1 commit into
xielixing wants to merge 1 commit into
Conversation
When restoring a historical session, the async hydration response could arrive after the user has already sent a new message. The hydration commit at FlowChatStore.ts was overwriting dialogTurns entirely with the restored turns, losing any turns added during the hydration window. This caused message action buttons (copy/edit/rollback) to become permanently unclickable for the session because the lost turn IDs were no longer in dialogTurns, making absoluteSessionTurnIndexForId return undefined and actionTurnIndex resolve to -1. Fix: merge restored turns with any turns added to the session during the hydration window, following the existing merge pattern already used in applyDialogTurnProjection (lines ~3080-3088). Fixes GCWing#1508
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a user clicks "Stop Generation" during an AI response, message operation buttons (copy, edit, rollback) occasionally become permanently unclickable for the entire conversation session. The tooltip shows "会话历史尚未就绪" (session history not ready).
Root Cause
The race condition occurs when restoring a historical session:
dialogTurnsFlowChatStore.tsoverwritesdialogTurnsentirely with restored turns, losing the new turndialogTurns→absoluteSessionTurnIndexForIdreturnsundefined→actionTurnIndex = -1→ buttons disabled, tooltip "会话历史尚未就绪"Fix
Merge restored turns with any turns that were added to the session during the async hydration window, following the existing merge pattern already used in
applyDialogTurnProjection(lines ~3080-3088 of the same file).This ensures turns created between the restore request and its response are preserved, preventing the button-disabled state.
Fixes #1508